/**
 * Created by Luji on 2017/03/27.
 */
class Edit {
    constructor(id , $modalInstance , userSrv , ctgNotification) {
        "ngInject";
        this._modalInstance = $modalInstance;
        this._notification  = ctgNotification;
        this._userSrv = userSrv;
        this.params = {
            id : id
        };

        this._userSrv.getUserItem(id).then(data=> {
            this.oldPassword = data.password;
        }).catch(()=> {
            this._notification.error('获取用户数据有误.');
        });
    }
    cancel() {
        this._modalInstance.dismiss('cancel');
    }
    save(){
        this._userSrv.editPassWord(this.params).then(data=> {
            this._modalInstance.close();
            this._notification.success('修改密码成功.');
        }).catch((data)=> {
            this._notification.error(data.resultMsg);
        });
    }
}
export default Edit